package org.hhchat.leetcode.array;

import java.util.Arrays;

/**
 * Created by hh23485 on 2017/8/22.
 * https://leetcode.com/problems/remove-element/description/
 */
public class code27_easy {
    static class Solution {
        public int removeElement(int[] nums, int val) {
            int i=0;
            for(int k=0;k<nums.length;k++){
                if(nums[k]==val){
                    continue;
                }
                nums[i]=nums[k];
                i++;
            }
            return i;
        }
    }
    public static void main(String[] args){
        Solution solution = new Solution();
        int[] arr = {3,2,2,3};
        System.out.println(solution.removeElement(arr,2));
        System.out.println(Arrays.toString(arr));
    }
}
